package com.blog.controller;

import com.blog.exception.ExceptionEnum;
import com.blog.pojo.AdminDashboardVO;
import com.blog.pojo.ResultResponse;
import com.blog.pojo.UserDashboardVO;
import com.blog.service.DashboardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping("/dashboard")
@RestController
public class DashboardController {
    @Autowired
    private DashboardService dashboardService;

    @GetMapping("/{identity}")
    public ResultResponse listData(@PathVariable Integer identity) {
        if(identity == 1) {
            new AdminDashboardVO();
            AdminDashboardVO adminDashboardVO;
            adminDashboardVO = dashboardService.listAdminData();
            return ResultResponse.success(adminDashboardVO);
        }
        if(identity == 0) {
            UserDashboardVO  userDashboardVO;
            userDashboardVO = dashboardService.listUserData();
            return ResultResponse.success(userDashboardVO);
        }
        return ResultResponse.error(ExceptionEnum.EMPTY_DATA);
    }
}
